# application/models/system/device.py
from sqlalchemy import Column, BigInteger, String, CHAR
from application.models.base import Base


class SysDevice(Base):
    """
    设备数据模型
    对应数据库表：device
    """

    __tablename__ = "sys_device"

    device_id = Column(
        BigInteger, primary_key=True, autoincrement=True, comment="设备id"
    )
    device_name = Column(String(32), nullable=False, comment="设备名称")
    device_model = Column(String(32), nullable=False, comment="设备型号")
    device_type = Column(String(8), nullable=False, comment="设备型号")
    manufacturer = Column(String(32), nullable=False, comment="制造厂商")
    device_status = Column(
        CHAR(1),
        nullable=False,
        comment="设备状态",
        default=0,
    )
    test_plan = Column(String(8), nullable=True, comment="测试方案")
    device_address = Column(String(8), nullable=True, comment="设备地址")
    communication_type = Column(CHAR(1), nullable=False, comment="通讯方式")
    serial_port = Column(String(32), nullable=True, comment="串口")
    baudrate = Column(String(32), nullable=True, comment="波特率")
    ip_address = Column(String(32), nullable=True, comment="IP地址")
    port = Column(String(32), nullable=True, comment="端口号")

    # 表注释
    __table_args__ = {"comment": "设备表"}
